Skip to content

Conversation

@upamune
Copy link
Contributor

@upamune upamune commented Apr 10, 2025

Context

This PR implements a YAML-based configuration system for custom modes, providing a more structured way for users to define custom modes and improving the developer experience.

Design Doc: https://hackmd.io/@upamune/roo-rule-directory

Implementation

The implementation includes:

  1. Zod Schema for Mode Configuration: Added src/modeSchemas.ts to implement Zod schemas for mode configurations, enabling type-safe configurations.

  2. JSON Schema Generation Script: Added scripts/generate-mode-schema.ts to generate JSON schema from Zod schema, enabling auto-completion and validation when editing YAML files in editors.

  3. Mode Configuration Service: Implemented src/services/ModeConfigService.ts to provide functionality for loading, saving, and managing mode configurations from both global and project-specific locations.

  4. Legacy Support: Maintained backward compatibility with existing .roomodes file format.

  5. Syntax Extensions: Added support for both V1 (tuple-based) and V2 (object-based) syntax, providing more flexible configuration options.

  6. Dependencies: Added js-yaml and zod-to-json-schema to support YAML file processing and JSON schema generation.

Screenshots

before after
Legacy .roomodes JSON file Structured configuration with new .roo/modes/*.yaml files

How to Test

  1. Create a .roo/modes/ directory and define a custom mode with a YAML file
  2. Define a mode with the following format:
name: Example Mode
roleDefinition: You are a specialized assistant for example tasks.
groups:
  - read
  - edit:
      fileRegex: /\.md$/
      description: Markdown files
  - command
  1. Restart VSCode and verify that the new mode is available
  2. If you have an existing .roomodes file, verify that those modes are still available

Get in Touch

Discord: @serizawa_

upamune added 8 commits April 11, 2025 00:27
- Introduced JSON and YAML fixtures for legacy v1, v2, and mixed syntax modes.
- Implemented unit tests for loading modes with v1 tuple-based syntax, v2 object-based syntax, and mixed syntax.
- Added compatibility tests to ensure v1 and v2 syntax are treated as equivalent.
- Created a debug test to validate the loading of modes from the filesystem.
- Enhanced the ModeConfigService to handle different syntax formats seamlessly.
- Removed global state dependencies and environment variable usage in tests.
- Consolidated mock setups within individual test cases to enhance readability.
- Adjusted expectations to align with the actual behavior of the implementation, ensuring tests reflect the expected outcomes when loading modes.
- Added comments for clarity on test intentions and behaviors.
- Enhanced debugging capabilities with console logs and spies where necessary.
… fixtures, update v2 syntax fixture for consistency
@changeset-bot
Copy link

changeset-bot bot commented Apr 10, 2025

⚠️ No Changeset found

Latest commit: be9565a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

…n .roo/modes directory and update create mode instructions for new format
@hannesrudolph hannesrudolph moved this from New to PR [Pre Approval Review] in Roo Code Roadmap Apr 10, 2025
@upamune upamune closed this Apr 13, 2025
@github-project-automation github-project-automation bot moved this from PR [Pre Approval Review] to Done in Roo Code Roadmap Apr 13, 2025
@upamune upamune deleted the brand-new-roomodes branch April 13, 2025 11:15
@hannesrudolph
Copy link
Collaborator

@upamune are you still interested in making a go of this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants